import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import dbTableFieldService from '/@/api/cn/core/data/dbTableFieldService'

import type { DbTableField } from '/@/model/cn/core/data/eo/DbTableField'
import type { DbTableFieldQO } from '/@/model/cn/core/data/qo/DbTableFieldQO'
import type { DbTableFieldVO } from '/@/model/cn/core/data/vo/DbTableFieldVO'

interface DbTableFieldState {
}

export const useDbTableFieldStore = defineStore({
  id: 'dbTableField',
  state: (): DbTableFieldState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<DbTableField>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.save(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<DbTableField>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.saveBatch(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<DbTableField>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.update(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<DbTableField>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.updateBatch(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<DbTableField>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.remove(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<DbTableField>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.removeBatch(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<DbTableFieldQO>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.count(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<DbTableFieldQO>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.pk(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<DbTableFieldQO>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.query(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<DbTableFieldQO>): Promise<Res<DbTableField>> {
      return new Promise<Res<DbTableField>>((resolve, reject) => {
        dbTableFieldService.paging(param).then((res: AxiosResponse<Res<DbTableField>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<DbTableFieldQO>): Promise<Res<DbTableFieldVO>> {
      return new Promise<Res<DbTableFieldVO>>((resolve, reject) => {
        dbTableFieldService.countVo(param).then((res: AxiosResponse<Res<DbTableFieldVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<DbTableFieldQO>): Promise<Res<DbTableFieldVO>> {
      return new Promise<Res<DbTableFieldVO>>((resolve, reject) => {
        dbTableFieldService.pkVo(param).then((res: AxiosResponse<Res<DbTableFieldVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<DbTableFieldQO>): Promise<Res<DbTableFieldVO>> {
      return new Promise<Res<DbTableFieldVO>>((resolve, reject) => {
        dbTableFieldService.queryVo(param).then((res: AxiosResponse<Res<DbTableFieldVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<DbTableFieldQO>): Promise<Res<DbTableFieldVO>> {
      return new Promise<Res<DbTableFieldVO>>((resolve, reject) => {
        dbTableFieldService.pagingVo(param).then((res: AxiosResponse<Res<DbTableFieldVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useDbTableFieldStoreWithout() {
  return useDbTableFieldStore(store)
}
